﻿@model Model.AppUserList
@{
    ViewBag.Title = "ReceiveMaterial";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model


@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#startDate").datebox("setValue", strDate);
            $("#endDate").datebox("setValue", strDate);

            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-exporter", function () {
            ExporterExcel();
        });

        HandleDom.ClassTriggerClick("icon-upload", function () {
            var startDate = $('#startDate').datebox('getValue');
            var endDate = $('#endDate').datebox('getValue');
            var status = $('#status').combobox('getValue');
            var selType = $('#selType').combobox('getValue');
            HandleRequest.submitForm('query', '@Url.Action("GetOrderInfo", "ReceiveMaterial")' + "?startDate=" + startDate + "&endDate=" + endDate + "&status=" + status + "&selType=" + selType, function (data) {
                console.log(data);
                eval('data=' + data);
                console.log(data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                } else {
                    layer.alert(data.msg, 9);
                }
            });
        });


        //初始化数据
        function InitGrid() {
            var startDate = $('#startDate').datebox('getValue');
            var endDate = $('#endDate').datebox('getValue');
            var status = $('#status').combobox('getValue');
            var selType = $('#selType').combobox('getValue');


            queryParams = {
                startDate: startDate,
                endDate: endDate,
                saleorderflag: status,
                selType: selType
            }
            HandleData.InitDataGrid('dg', '/ReceiveMaterial/InitJsonResult', 'toolbar', queryParams, 'GOODSCODE', false, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
        //导出预估生产单
        function ExporterExcel() {
            var form = $('#query');

            var startDate = $('#startDate').datebox('getValue');
            var endDate = $('#endDate').datebox('getValue');
            var status = $('#status').combobox('getValue');
            var selType = $('#selType').combobox('getValue');

            form.form('submit', {
                url: '@Url.Content("~/ReceiveMaterial/ExporterExcel")' + "?startDate=" + startDate + "&endDate=" + endDate + "&status=" + status + "&selType=" + selType,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('导出成功!', 9);
                    } else {
                        layer.alert(data.msg, 3);
                    }
                }
            });
        }


</script>
}
<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>

                    <td>
                        配送时间:
                    </td>
                    <td>
                        <input class="easyui-datebox" id="startDate" name="startDate" style="width: 140px;" />
                    </td>
                    <td>
                        ~：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="endDate" name="endDate" style="width: 140px;" validtype="compareDate['#startDate']" />
                    </td>
                    <td>
                        订单状态:
                    </td>
                    <td>
                        <select id="status" name="status" class="easyui-combobox">
                            <option value="0">未确认</option>
                            <option value="1">已确认</option>
                        </select>
                    </td>
                    <td>
                        配送类型:
                    </td>
                    <td>
                        <select id="selType" name="selType" class="easyui-combobox">
                            <option value="0">无</option>
                            <option value="1">当日达</option>
                            <option value="2">次日达</option>
                        </select>
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid();">查询</a>

                    </td>

                </tr>
            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="领料单信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'GOODSCODE',width:50">商品编码</th>
                    <th data-options="field:'GOODSNAME',width:100">商品名称</th>
                    <th data-options="field:'SUMQTY',width:180">数量</th>
                    <th data-options="field:'UNITNAME',width:80">库存单位</th>
                    <th data-options="field:'PURUNITQTY',width:80">大单位数量</th>
                    <th data-options="field:'PURUNITNAME',width:80">采购单位</th>
                    <th data-options="field:'GOODSSPEC',width:80">规格</th>
                    <th data-options="field:'LOOKUP',width:80">库位</th>
                    <th data-options="field:'STATUS',width:80">状态</th>
                    <th data-options="field:'RATIONDATE',width:100">配送时间</th>
                </tr>
            </thead>
        </table>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =false },
              new FunctionModule(){Name = "Edit",IsEnable =false },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              new FunctionModule(){Name = "Upload",IsEnable =true },

            }
        }
    }
})

</body>

